<!-- inc:header -->
<div class="notice"><div class="p">
	<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td><span class="lead">&nbsp;&raquo; <a href="{:site_url('lang')}">语言包管理</a> <span class="red">{:$rs[title]}</span>&nbsp;&raquo; 语言变量管理</span></td>
		<td align="right"><a href="{:site_url('lang,plset')}id={:$id}" class="button">批量添加变量</a></td>
	</tr>
	</table>
</div></div>

<div class="main">
<table width="100%" style="layout:fixed;" cellpadding="0" cellspacing="0">
<tr>
	<td class="t_sub" width="40px">ID</td>
	<td class="t_sub" width="60px">范围</td>
	<td class="t_sub" width="200px">变量名</td>
	<td class="t_sub">值</td>
</tr>
<tr class="tr_out" onMouseOver="over_tr(this)" onMouseOut="out_tr(this)">
	<td align='center' class="tc_left">添加</td>
	<td align='center' class="tc_right"><select name="ltype_add" id="ltype_add">
		<option value="all">全局</option>
		<option value="www">前台</option>
		<option value="admin">后台</option></select></td>
	<td align="center" class="tc_right"><input type="text" name="var_add" id="var_add" /></td>
	<td align='left' class="tc_right" style="padding-left:5px;">
		<input type="text" name="val_add" id="val_add" class="long_input" />
		<input type="button" value="添加" onclick="setok('add')" />
	</td>
</tr>
<!-- $rslist AS $key=>$value -->
<tr class="tr_out" onMouseOver="over_tr(this)" onMouseOut="out_tr(this)">
	<td align='center' class="tc_left">{:$value[id]}</td>
	<td align='center' class="tc_right">{:$ltype[$value[ltype]]}</td>
	<td align="left" class="tc_right">&nbsp;{:$value['var']}</td>
	<td align='left' class="tc_right" style="padding-left:5px;">
		<input type="text" name="val_{:$value[id]}" id="val_{:$value[id]}" value="{:$value[val]}" class="long_input" />
		<input type="button" value="编辑" onclick="setok('{:$value[id]}')" />
		<input type="button" value="删除" onclick="del({:$value['id']})" />
	</td>
</tr>
	<!-- if(($key+1)%20 == "") -->
	<tr>
		<td class="t_sub">ID</td>
		<td class="t_sub">范围</td>
		<td class="t_sub">变量名</td>
		<td class="t_sub">值</td>
	</tr>
	<!-- end -->
<!-- end -->
</table>
</div>
<script type="text/javascript">
function del(id)
{
	if(!id)
	{
		alert("操作非法");
		return false;
	}
	var q = confirm("确定要删除此信息吗？删除后是不能恢复的");
	if(q != 0)
	{
		var url = base_url + base_func + "=ajax_lang_del&id="+id;
		var msg = get_ajax(url);
		if(!msg) msg = "error: 操作非法";
		if(msg == "ok")
		{
			window.location.href = window.location.href;
		}
		else
		{
			alert(msg);
			return false;
		}
	}
}

function setok(tid)
{
	var url = "{:site_url('lang,ajax_setok')}langid={:$id}&";
	if(tid != "add")
	{
		url += "id="+tid+"&";
		var note = getid("val_"+tid).value;
		if(!note)
		{
			alert("值不允许为空");
			return false;
		}
		url += "val="+EncodeUtf8(note);
	}
	else
	{
		var ltype = getid("ltype_add").value;
		var tvar = getid("var_add").value;
		var val = getid("val_add").value;
		if(!ltype || !tvar || !val)
		{
			alert("内容不允许为空");
			return false;
		}
		url += "ltype="+ltype+"&var="+EncodeUtf8(tvar)+"&val="+EncodeUtf8(val);
	}
	var msg = get_ajax(url);
	if(msg != "ok")
	{
		if(!msg) msg = "Error: 操作失败";
		alert(msg);
		return false;
	}
	else
	{
		if(tid == "add")
		{
			window.location.href = window.location.href;
		}
		else
		{
			alert("添加/修改变量信息操作成功");
		}
		return true;
	}
}
</script>
<!-- inc:footer -->